<?php

namespace App\View\Components;

use App\Models\Warranty;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\View\Component;

class NewPrecutFpart extends Component
{
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct(Request $request, Warranty $warranty)
    {
        $this->warranty = $warranty;
        $this->precut_id = $warranty->precut_id;
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\View\View|string
     */
    public function render()
    {
        $items = $this->getItems();
        return view('components.new-precut-fpart', [
            'items' => $items,
        ]);
    }

    public function getItems()
    {
        if (empty($this->precut_id)) {
            return [];
        } else {
            $items = \App\Models\NewPrecutFpart::where('precut_id', $this->precut_id)
                ->get();
            return $items;
        }

    }
}
